<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/css/backStageBase.css}">
</head>
<body class="layui-layout-body">
    <div id="backstage" class="layui-layout layui-layout-admin">
        <div class="layui-header layui-bg-blue" >
            <div class="layui-logo">青木良品</div>
            <ul class="layui-nav  layui-layout-left" lay-filter="">
                <li class="layui-nav-item">用户管理</li>
            </ul>
            <ul class="layui-nav layui-layout-right layui-bg-blue">
                <li class="layui-nav-item" th:text="${session.user.name}">
                </li>
                <li class="layui-nav-item"><a href="/mall/user/logout.do">退出</a></li>
            </ul>
        </div>

        <div class="layui-side layui-bg-gray">
            <ul class="layui-nav layui-nav-tree layui-bg-blue" lay-filter="test">
                <!-- 侧边导航: <ul class="layui-nav layui-nav-tree layui-nav-side"> -->
                <li class="layui-nav-item"><a th:href="@{/admin/product/toList.html}">商品管理</a></li>
                <li class="layui-nav-item"><a th:href="@{/admin/activity/toList.html}">活动管理</a></li>
                <li class="layui-nav-item"><a th:href="@{/admin/order/toList.html}">订单管理</a></li>
                <li class="layui-nav-item layui-nav-itemed"><a th:href="@{/admin/user/toList.html}">用户管理</a></li>
            </ul>
        </div>
        <div class="layui-body" style="overflow: hidden;height: 650px">
            <table id="userList"></table>
        </div>
    </div>
</body>
<script th:src="@{/js/jqurey.js}"></script>
<script th:src="@{/layui/layui.js}"></script>
<script type="text/javascript">
    layui.use(['element','form','table','layer'], function(){
        var element = layui.element;
        var form = layui.form;
        var layer = layui.layer;
        // 表格渲染
        var table = layui.table
        table.render({
            elem: '#userList',
            height: 600,
            cols: [ [
                {field: 'id', title: 'ID', width: 110, sort:true},
                {field: 'name', title: '用户名称', width: 150},
                {field: 'status', title: '用户状态', width: 120, templet:function(d){
                    if(d.status=='1'){return '<span>普通用户</span>'}
                    else if(d.status=='2'||d.status=='3'){return '<span>管理员</span>'}
                }},
                {field: 'telephone', title: '联系电话', width: 180},
                {field: 'address1', title: '收货地址', width: 250},
                {field: 'email', title: '电子邮箱', width: 250},
                {field: 'opera', title: '操作', width: 140, templet:function(d){return '<a href="/mall/admin/user/toEdit.html?id='+d.id+'"><button class="layui-btn layui-btn-sm">修改</button></a>'}}
            ]],
            url: 'list.do',
            // parseData: function (res) {
            //     return{
            //         "msg": res.message, //解析提示文本
            //         "data": res.data, //解析数据列表
            //         "count": res.data.length, //解析数据长度
            //     }
            // }
            response: {
                statusName: 'state' //规定数据状态的字段名称，默认：code
                ,statusCode: 0 //规定成功的状态码，默认：0
                ,msgName: 'message' //规定状态信息的字段名称，默认：msg
                ,dataName: 'data' //规定数据列表的字段名称，默认：data
            }
        })
    });
    $(function () {
        getData(1)
        getData2()
    })
    function getData(pageindex) {
        $.ajax({
            //请求方式
            type : "GET",
            //请求的媒体类型
            contentType: "application/json;charset=UTF-8",
            //请求地址
            url : "list.do?pageindex="+pageindex,
            //请求成功
            success : function(data) {

            },
            error : function (e) {

            }
        });
    }
    function getData2() {
        $.ajax({
            //请求方式
            type : "GET",
            //请求的媒体类型
            contentType: "application/json;charset=UTF-8",
            //请求地址
            url : "getTotal.do?",
            //请求成功
            success : function(data) {

            },
            error : function (e) {

            }
        });
    }
</script>
</html>